package com.ExecutorsThreads;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

//直接创建线程池对象
public class MyThreadPool {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                5,//核心线程数
                10,//最大线程数
                10,//空闲线程的最大使用时间
                TimeUnit.SECONDS,//时间单位
                new ArrayBlockingQueue<>(10),//任务队列
                Executors.defaultThreadFactory(),//创建线程工厂
                new ThreadPoolExecutor.AbortPolicy());//拒绝策略
//开启线程
        threadPoolExecutor.submit(new MyThreads());
//        关闭线程
        threadPoolExecutor.shutdown();

    }
}
